import { BaseCommand } from '@amcax/base';
import { DefaultEventCenter } from '@app-base/common/events/DefaultEventCenter';
import { PICKTYPE } from '@app-base/common/events/EventCenter3D';
import { eventCenterManager } from '../../events/EventCenterManager';

const createPickCommand = (
  id: string,
  label: string,
  icon: string,
  pickType: PICKTYPE,
): BaseCommand => ({
  id,
  label,
  icon,
  invoke: () => {
    (eventCenterManager.activeEventCenter as DefaultEventCenter).setPickType(
      pickType,
    );
  },
  noHighlight: true,
});

export const cmdPickPoint = createPickCommand(
  'CmdPickPoint',
  'command.pick-mode-point',
  'commands/common/pick-mode-point',
  PICKTYPE.POINT,
);
export const cmdPickLine = createPickCommand(
  'CmdPickLine',
  'command.pick-mode-line',
  'commands/common/pick-mode-line',
  PICKTYPE.LINE,
);
export const cmdPickFace = createPickCommand(
  'CmdPickFace',
  'command.pick-mode-face',
  'commands/common/pick-mode-face',
  PICKTYPE.FACE,
);
export const cmdPickModel = createPickCommand(
  'CmdPickModel',
  'command.pick-mode-model',
  'commands/common/pick-mode-model',
  PICKTYPE.MODEL,
);
export const cmdPickSmart = createPickCommand(
  'CmdPickSmart',
  'command.pick-mode-smart',
  'commands/common/pick-mode-smart',
  PICKTYPE.ALL,
);
